function get_time_difference(earlierDate,laterDate)
{
       var nTotalDiff = laterDate.getTime() - earlierDate.getTime();
       var oDiff = new Object();
 
       oDiff.days = Math.floor(nTotalDiff/86400000);
       nTotalDiff -= oDiff.days*86400000;
 
       oDiff.hours = Math.floor(nTotalDiff/3600000);
       nTotalDiff -= oDiff.hours*3600000;
 
       oDiff.minutes = Math.floor(nTotalDiff/60000);
       nTotalDiff -= oDiff.minutes*60000;
 
       oDiff.seconds = Math.floor(nTotalDiff/1000);
 
       return oDiff;
 
}
var product_interval_id =0;
jQuery(document).ready(function($) {
	function setTime(){
		var end_date = new Date($('#product-timer-end').val()*1000);
		var now = new Date();
		var diff =get_time_difference(now,end_date);
        if(diff.days >=0  && diff.hours >=0 && diff.minutes >=0 && diff.seconds >=0 ){
            jQuery('#product-timer').html(diff.days +" day(s):"+ diff.hours +" hour(s):"+diff.minutes+" minute(s):"+diff.seconds+" second(s)");
        }else{
            clearInterval(product_interval_id);
        }
        
	}
    var end_date = new Date($('#product-timer-end').val()*1000);
	var now = new Date();
	var diff =get_time_difference(now,end_date);
    if(diff.days >=0  && diff.hours >=0 && diff.minutes >=0 && diff.seconds >=0 ){
        setTime();
        product_interval_id = setInterval(setTime,1000);
    }
});